/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-30 17:50:06
 * @LastEditTime: 2021-08-30 19:27:40
 * @LastEditors: changqing
 * @Usage: 
 */
var { timer, interval,range,from,Subject } = require('rxjs'); 
var {debounce,map} = require('rxjs/operators');

// debounce和debounceTime都是在一段时序内没有新事件才会让些事件值发生。差别在于debounce可以传入durationSelector的callback function，debounce会将来源Observable事件值传入durationSelector，并返回一个用来控制时间的Observable或Promise

const source = interval(3000);
const durationSelector = (value) => interval(value * 1000);
source.pipe(
 debounce(durationSelector)
).subscribe(data => {
  console.log(`${data}`);
});
// 0 1 2